package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created by cc
 * Description:
 * User: CZH
 * Date: 2022-09-24
 * Time: 14:31
 */
public class AddOperation implements IOPeration {
    @Override
    public void work(BookList bookList) {
        System.out.println("添加图书~");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入书名：");
        String name = scanner.nextLine();
        System.out.println("请输入作者：");
        String author = scanner.nextLine();
        System.out.println("请输入价格：");
        String price = scanner.nextLine();
        System.out.println("请输入类型：");
        String type = scanner.nextLine();
        Book book = new Book(name,author,price,type);
        int size = bookList.getBookSize();
        bookList.setBooks(size, book);
        bookList.setBookSize(size + 1);
        System.out.println("图书添加成功！");
    }
}
